/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import com.sun.lwuit.CheckBox;
import com.sun.lwuit.Command;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.layouts.BoxLayout;
import core.ScreenEngine;
import core.Settings;
import view.commands.BackCommand;

/**
 *
 * @author Kvest
 */
public class VibrationSettingsForm extends BasicForm
{
    private static final int ACCEPT_COMMAND_ID = 1;

    private CheckBox cbVibration;
    
    public VibrationSettingsForm()
    {
        super("vibration");
        
        init();
    }
    
    private void init()
    {
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        setCyclicFocus(false);
        
        cbVibration = new CheckBox("vibration");
        cbVibration.setSelectCommandText("");
        addComponent(cbVibration);
        
        addCommand(new BackCommand());
        
        Command accept = new Command("accept", ACCEPT_COMMAND_ID)
        {
            public void actionPerformed(ActionEvent evt)
            {   
                Settings.getSettings().setVibration(cbVibration.isSelected());
                 
                ScreenEngine.getEngine().popTo(0);
                
                evt.consume();
            }
        };
        addCommand(accept);
    }
    
    public void show()
    {
        setContent();
        
        super.show();
    }
    
    private void setContent()
    {
        cbVibration.setSelected(Settings.getSettings().isVibration());
    }
}
